<template>
	<div class="nav-header">
		<el-icon class="icon-fold" v-if="isFold" @click="handleFoldClick"
			><Fold
		/></el-icon>
		<el-icon class="icon-fold" v-else @click="handleFoldClick"
			><Expand
		/></el-icon>
		<div class="content">
			<HyBreadcrumb :breadcrumbs="breadcrumbs"></HyBreadcrumb>
			<div><userInfo></userInfo></div>
		</div>
	</div>
</template>

<script lang="ts">
	import userInfo from './user-info.vue'
	import { defineComponent, ref, computed } from 'vue'
	import HyBreadcrumb, { IBreadCrumb } from '@/base-ui/breadcrumb/index'
	import { pathMapBreadcrumbs } from '@/utils/map-menus'
	import { useStore } from 'vuex'
	import { useRoute } from 'vue-router'
	export default defineComponent({
		emits: ['foldChange'],
		components: { userInfo, HyBreadcrumb },
		setup(props, { emit }) {
			const isFold = ref<boolean>(false)
			const store = useStore()
			const route = useRoute()
			let breadcrumbs = computed(() => {
				const userMenus = store.state.loginModule.userMenus
				let currentPath = route.path
				return pathMapBreadcrumbs(userMenus, currentPath)
			})
			const handleFoldClick = () => {
				isFold.value = !isFold.value
				emit('foldChange', isFold.value)
			}
			return {
				isFold,
				handleFoldClick,
				breadcrumbs
			}
		}
	})
</script>

<style lang="less" scoped>
	.nav-header {
		width: 100%;
		display: flex;
		align-items: center;
		.icon-fold {
			font-size: 30px;
			cursor: pointer;
		}
		.content {
			flex: 1;
			display: flex;
			padding: 0 20px;
			align-items: center;
			justify-content: space-between;
		}
	}
</style>